package com.xuxueli.applyModules.utils;
import com.xuxueli.applyModules.entity.DcBillTmpParam;
import com.xuxueli.applyModules.entity.KeyValuePair;
import org.apache.http.entity.ContentType;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class TeatExcelRead {

    /**
     * 测试文件
     * @RequestParam("file") MultipartFile file,
     * @RequestParam("startRow") int startRow
     * @param args
     */
    public static void main(String[] args) {
        File pdfFile = new File("D://test.pdf");
        FileInputStream fileInputStream = null;
        MultipartFile multipartFile = null;
        try {
            fileInputStream = new FileInputStream(pdfFile);
            multipartFile = new MockMultipartFile(pdfFile.getName(), pdfFile.getName(),
                    ContentType.APPLICATION_OCTET_STREAM.toString(), fileInputStream);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        int startRow = 8;
        List<KeyValuePair<String,String>> headList=new ArrayList<>();
        List<KeyValuePair<String,String>> listList=new ArrayList<>();
        headList.add(new KeyValuePair<>("agentCode", "单位编码"));
        headList.add(new KeyValuePair<>("iEMark", "标志"));
        headList.add(new KeyValuePair<>("trafMode", "方式"));

        listList.add(new KeyValuePair<>("copGNo", "料号"));
        listList.add(new KeyValuePair<>("gNo", "序号"));
        listList.add(new KeyValuePair<>("rotateGNo", "报表序号"));
        listList.add(new KeyValuePair<>("gModel", "规格型号"));

        try {
            DcBillTmpParam dcBillData = ExcelImportUtil.readIntegration(multipartFile.getInputStream(), "核注清单", startRow, headList, listList);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        }

    }
}
